namespace Brjnk.GpxExplorer.Workspace
{
    using System.Xml;
    using Brjnk.Common;

    /// <summary>
    /// </summary>
    public static class GeoNamesHelper
    {
        public static PlaceInfo GetPlaceInfo(XmlElement element)
        {
            PlaceInfo info = new PlaceInfo();
            info.Name = element.GetElementsByTagName("toponymName").Item(0).InnerText;
            double lat = double.Parse(element.GetElementsByTagName("lat").Item(0).InnerText, System.Globalization.CultureInfo.InvariantCulture);
            double lng = double.Parse(element.GetElementsByTagName("lng").Item(0).InnerText, System.Globalization.CultureInfo.InvariantCulture);
            info.Position = new GpsCoordinates(lat, lng);
            return info;
        }
    }

    public struct PlaceInfo
    {
        public string Name { get; set; }

        public GpsCoordinates Position { get; set; }
    }
}